package com.weiyi.portal.controller;

import com.weiyi.common.common.api.CommonResult;
import com.weiyi.portal.modules.ums.model.UmsNews;
import com.weiyi.portal.modules.ums.service.UmsFriendsRelationService;
import com.weiyi.portal.modules.ums.service.UmsNewsService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "用户关注页")
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    UmsFriendsRelationService friendsRelationService;
    @Autowired
    UmsNewsService newsService;

    /**
     * 根据用户id获取其关注列表
     * @param id
     * @return
     */
    @RequestMapping("/getAllFollowerId")
    public CommonResult getFollowId(@RequestBody Integer id){
        List<String> friends = friendsRelationService.getFriends(id);
        return CommonResult.success(friends);
    }

    /**
     * 根据用户id获取其发布的动态
     * @param id
     * @return
     */
    @RequestMapping("/getNewsByUserId")
    public CommonResult getNewsByUserId(@RequestBody Integer id){
        List<UmsNews> news = newsService.getNewsById(id);
        return CommonResult.success(news);
    }
}
